<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        window.onload=function(){
            // var ps=document.getElementsByTagName("p");//获取所有的p元素
            // console.log(ps);

            // var ps=document.querySelectorAll("div>p");
            // console.log(ps);


            var div=document.querySelector("div");//获取div的DOM对象
            // DOM对象.getElementsByTagName("标签名")在指定元素内部根据标签名称查找元素
            var ps=div.getElementsByTagName("p");
            console.log(ps);

            //在元素内部可以根据DOM对象.getElementsByTagName()，DOM对象.getElementsByClassName()查找的
           console.log( div.getElementsByClassName("a"));
        };
    </script>
</head>

<body>
    <div>
        <p class="a">p01</p>
        <p>p02</p>
        <p>p03</p>
        <p>
            ppp
            <span>ssss</span>
        </p>
        <span>span</span>
    </div>
    <p>p04</p>
    <p>p05</p>
    <p>p06</p>
</body>

</html>